package ypmits.utils {
	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.utils.Timer;
	import flash.utils.getTimer;	

	/**
	 * @author Dave Lenz
	 */
	public class TimerDebug extends Sprite {

		private var timer : Timer;
		private var startTime : int;
		private var time : Number;
		private var tf : TextField;

		
		public function TimerDebug() {
			timer = new Timer( 1000 / 60, 0 );
			timer.addEventListener( TimerEvent.TIMER, handleTimerUpdate );
			
			tf = new TextField( );
			tf.textColor = 0xFFFFFF;
			addChild( tf );
			
			graphics.beginFill( 0x000000, 1 );
			graphics.drawRect( 0, 0, tf.width, 15 );
		}

		
		public function start() : void {
			time = 0;
			startTime = getTimer( );
			timer.start( );
		}

		
		private function handleTimerUpdate(event : TimerEvent) : void {
			time = .001 * (getTimer( ) - startTime);
			tf.text = (Math.floor( 100 * time ) / 100).toString( );
		}
	}
}
